<template>
  <div class="navMenu">

    <label v-for="navMenu in navMenus">
      <el-menu-item v-if="navMenu.children == null || navMenu.children.length ===0"
                    :key="navMenu.id" :data="navMenu" :index="'/'+navMenu.code" :route="'/'+navMenu.code">
        <i :class="navMenu.icon" class="el-icon-menu"></i>
        <span slot="title">{{navMenu.name}}</span>
      </el-menu-item>

      <el-submenu v-if="navMenu.children && navMenu.children.length >0"
                  :key="navMenu.id" :data="navMenu" :index="'/'+navMenu.code">
        <template slot="title">
          <i :class="navMenu.icon" class="el-icon-menu"></i>
          <span> {{navMenu.name}}</span>
        </template>

        <NavMenu :navMenus="navMenu.children"></NavMenu>
      </el-submenu>
    </label>

  </div>
</template>

<script>
  export default {
    name: 'NavMenu',
    props: {
      navMenus: {
        type: Array,
        default: function () {
          return []
        }
      },
    },
    data() {
      return {}
    },
    methods: {}
  }
</script>

<style scoped>

</style>
